package cn.jx.asc.mqtt.runner;


import cn.jx.asc.mqtt.MqClient;
import cn.jx.asc.parseupload.OkHttpUtil2;
import com.sun.org.apache.bcel.internal.generic.NEW;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
 * @author z423
 * @2021-06-13-17:16
 * @effect   统一启动时连接onenet自动订阅
 * @especial
 */
@Slf4j
@Order(value = 2)
@Component
public class MqttRunner implements ApplicationRunner {

    @Resource
    private MqClient mqClient;

    /**
     * Mqtt 启动类
     * @param args 参数
     */
    @Override
    public void run(ApplicationArguments args) {

        boolean connect = mqClient.connect();
        if(connect){
            log.info("Mqtt 正在接收数据...");
            OkHttpUtil2 okHttpUtil2 = new OkHttpUtil2();
           // okHttpUtil2.issue("A,9");
        }else{
            log.error("MqttRunner --> run 异常...");
        }

    }
}
